package com.vates.vsp.practico.alumnos.service;

import java.util.Collection;
import java.util.List;

import org.springframework.stereotype.Repository;

import com.vates.vsp.practico.alumnos.business.Alumnos;
import com.vates.vsp.practico.commons.AbstractBaseService;

@Repository("alumnosService")
public class AlumnosServiceImpl extends AbstractBaseService implements AlumnosService {

	/* (non-Javadoc)
	 * @see com.vates.vsp.practico.alumnos.service.AlumnosService#getAlumno(java.lang.Integer)
	 */
	@Override
	public Alumnos getAlumno(Integer id) {
		return this.get(Alumnos.class, id);
	}

	/* (non-Javadoc)
	 * @see com.vates.vsp.practico.alumnos.service.AlumnosService#guardarAlumno(com.vates.vsp.practico.alumnos.business.Alumnos)
	 */
	@Override
	public void guardarAlumno(Alumnos alumno) {
		this.getHibernateTemplate().saveOrUpdate(alumno);
	}

	/* (non-Javadoc)
	 * @see com.vates.vsp.practico.alumnos.service.AlumnosService#eliminarAlumno(com.vates.vsp.practico.alumnos.business.Alumnos)
	 */
	@Override
	public void eliminarAlumno(Alumnos alumno) {
		this.getHibernateTemplate().delete(alumno);
	}

	/* (non-Javadoc)
	 * @see com.vates.vsp.practico.alumnos.service.AlumnosService#getAllAlumnos()
	 */
	@Override
	public List<Alumnos> getAllAlumnos() {
		List<Alumnos> result = this.getHibernateTemplate().find("FROM Alumnos");
		return result;
	}
	
	/* (non-Javadoc)
	 * @see com.vates.vsp.practico.alumnos.service.AlumnosService#guardarAlumnos(java.util.Collection)
	 */
	@Override
	public void guardarAlumnos(Collection<Alumnos> alumnos){
		this.getHibernateTemplate().saveOrUpdateAll(alumnos);
	}
	
	/* (non-Javadoc)
	 * @see com.vates.vsp.practico.alumnos.service.AlumnosService#eliminarAlumnos(java.util.Collection)
	 */
	@Override
	public void eliminarAlumnos(Collection<Alumnos> alumnos){
		this.getHibernateTemplate().deleteAll(alumnos);
	}

	@Override
	public List<Integer> getAllIdAlumnos() {
		List<Integer> result= this.getHibernateTemplate().find("SELECT id FROM Alumnos");
		return result;
	}

	
	

}
